<template>
  <div class="home-container">
    <!-- 首页轮播 -->
    <div class="banner" @mouseenter="stopBannerRotation" @mouseleave="startBannerRotation">
      <div class="banner-slides">
        <div 
          v-for="(banner, index) in banners" 
          :key="banner.id"
          class="banner-slide"
          :class="{ active: index === currentSlide }"
          :style="{ background: banner.bgColor }"
        >
          <div class="banner-bg"></div>
          <div class="banner-content">
            <h1 class="banner-title">{{ banner.title }}</h1>
            <p class="banner-subtitle">{{ banner.subtitle }}</p>
            <el-button type="primary" size="large" class="banner-button" @click="goToProducts">立即浏览</el-button>
          </div>
        </div>
      </div>
      
      <!-- 轮播指示器 -->
      <div class="banner-indicators">
        <span 
          v-for="(banner, index) in banners" 
          :key="banner.id"
          class="indicator"
          :class="{ active: index === currentSlide }"
          @click="goToSlide(index)"
        ></span>
      </div>
      
      <!-- 轮播控制按钮 -->
      <button class="banner-control banner-prev" @click="prevSlide">
        &lt;
      </button>
      <button class="banner-control banner-next" @click="nextSlide">
        &gt;
      </button>
    </div>

    <!-- 搜索栏 -->
    <div class="search-section">
      <el-input
        v-model="searchKeyword"
        placeholder="搜索商品"
        suffix-icon="el-icon-search"
        class="search-input"
        @keyup.enter="searchProducts"
      />
      <el-button type="primary" @click="searchProducts">
        <el-icon><i-ep-search /></el-icon> 搜索
      </el-button>
    </div>

    <!-- 商品分类 -->
    <div class="categories-section">
      <div class="section-header">
        <h2>商品分类</h2>
        <el-link type="primary" @click="goToProducts">查看全部</el-link>
      </div>
      <div class="category-list">
        <div 
          v-for="category in categories" 
          :key="category.id"
          class="category-item"
          @click="goToCategory(category.id)"
        >
          <div class="category-icon">{{ category.name.charAt(0) }}</div>
          <span>{{ category.name }}</span>
        </div>
        <!-- 如果没有分类数据，显示默认分类 -->
        <div v-if="categories.length === 0" class="no-categories">
          暂无分类数据
        </div>
      </div>
    </div>

    <!-- 精选商品展示（少量精选，完整列表在商品页面） -->
    <div class="featured-products-section">
      <div class="section-header">
        <h2>精选商品</h2>
        <el-link type="primary" @click="goToProducts">查看全部商品</el-link>
      </div>
      <div class="product-grid">
        <div v-for="product in featuredProducts" :key="product.id" class="product-card card-hover">
          <router-link :to="`/product/${product.id}`">
            <div class="product-image">
              <div v-if="isLoading" class="loading-skeleton" style="height: 220px; background: #f0f0f0;"></div>
              <img
                v-else
                :src="product.images?.[0] || product.image"
                @error="handleImageError"
                class="product-img"
                alt="商品图片"
                loading="lazy"
              />
              <div class="product-discount" v-if="product.discount">
                {{ product.discount }}折
              </div>
            </div>
            <div class="product-info">
              <h3 class="product-title">{{ product.title }}</h3>
              <div class="product-price">¥{{ product.price }}</div>
              <div class="product-meta">
                <span>{{ product.categoryName || product.category }}</span>
                <span>{{ product.createdAt || product.publishTime }}</span>
              </div>
            </div>
          </router-link>
          <button 
            class="favorite-btn" 
            @click.stop="toggleFavorite(product)"
            :class="{ active: product.favorite }"
            title="收藏"
            aria-label="收藏"
          >
            <i v-if="product.favorite" class="el-icon-star-on"></i>
            <i v-else class="el-icon-star-off"></i>
          </button>
        </div>
        <div v-if="featuredProducts.length === 0" class="no-products">
          暂无商品数据
        </div>
      </div>
    </div>

    <!-- 平台优势 -->
    <div class="advantages-section">
      <h2>平台优势</h2>
      <div class="advantages-list">
        <div class="advantage-item">
          <div class="advantage-icon">
            <el-icon><i-ep-shield /></el-icon>
          </div>
          <h3>安全交易</h3>
          <p>实名认证，保障交易安全</p>
        </div>
        <div class="advantage-item">
          <div class="advantage-icon">
            <el-icon><i-ep-location /></el-icon>
          </div>
          <h3>校园配送</h3>
          <p>校内配送，便捷快速</p>
        </div>
        <div class="advantage-item">
          <div class="advantage-icon">
            <el-icon><i-ep-money /></el-icon>
          </div>
          <h3>价格透明</h3>
          <p>价格公开，童叟无欺</p>
        </div>
        <div class="advantage-item">
          <div class="advantage-icon">
            <el-icon><i-ep-help /></el-icon>
          </div>
          <h3>贴心服务</h3>
          <p>7×24小时客服支持</p>
        </div>
      </div>
    </div>

    <!-- 平台功能导航 -->
    <div class="features-nav-section">
      <h2>平台功能</h2>
      <div class="features-nav-grid">
        <router-link to="/products" class="feature-nav-card">
          <el-icon class="feature-nav-icon"><i-ep-goods /></el-icon>
          <h3>浏览商品</h3>
          <p>发现校园优质二手物品</p>
        </router-link>
        <router-link to="/publish" class="feature-nav-card">
          <el-icon class="feature-nav-icon"><i-ep-plus /></el-icon>
          <h3>发布商品</h3>
          <p>轻松出售你的闲置物品</p>
        </router-link>
        <router-link to="/cart" class="feature-nav-card">
          <el-icon class="feature-nav-icon"><i-ep-shopping-cart /></el-icon>
          <h3>购物车</h3>
          <p>管理你想要购买的商品</p>
        </router-link>
        <router-link to="/orders" class="feature-nav-card">
          <el-icon class="feature-nav-icon"><i-ep-document /></el-icon>
          <h3>我的订单</h3>
          <p>查看和管理你的订单</p>
        </router-link>
      </div>
    </div>

    <!-- 用户评价 -->
    <div class="testimonials-section">
      <h2>用户评价</h2>
      <div class="testimonials-carousel">
        <div v-for="testimonial in testimonials" :key="testimonial.id" class="testimonial-item card-hover">
          <div class="testimonial-content">
            <el-rate v-model="testimonial.rating" disabled show-score />
            <p class="testimonial-text">{{ testimonial.content }}</p>
            <div class="testimonial-author">
              <span class="author-name">{{ testimonial.name }}</span>
              <span class="author-title">{{ testimonial.role }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 使用指南 -->
    <div class="guide-section">
      <div class="section-header">
        <h2>快速上手</h2>
        <el-link type="primary" @click="goToGuide">查看完整指南</el-link>
      </div>
      <div class="guide-steps">
        <div class="guide-step">
          <div class="step-number">1</div>
          <div class="step-content">
            <h3>注册账号</h3>
            <p>使用学号快速注册，安全认证</p>
          </div>
        </div>
        <div class="guide-step">
          <div class="step-number">2</div>
          <div class="step-content">
            <h3>浏览商品</h3>
            <p>搜索和筛选你感兴趣的商品</p>
          </div>
        </div>
        <div class="guide-step">
          <div class="step-number">3</div>
          <div class="step-content">
            <h3>联系卖家</h3>
            <p>安全沟通，确认商品细节</p>
          </div>
        </div>
        <div class="guide-step">
          <div class="step-number">4</div>
          <div class="step-content">
            <h3>完成交易</h3>
            <p>线下见面或校内配送，安全交易</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, computed } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { useProductStore } from '../store/index.js'
import { useUserStore } from '../store/index.js'

const productStore = useProductStore()
const userStore = useUserStore()

const router = useRouter()
const searchKeyword = ref('')
const currentSlide = ref(0)

// 从store获取数据
const categories = computed(() => productStore.categories || [])
const featuredProducts = computed(() => {
  // 结合热门商品和推荐商品
  const products = [...(productStore.hotProducts || []), ...(productStore.recommendedProducts || [])]
  // 去重
  const uniqueProducts = products.filter((product, index, self) =>
    index === self.findIndex(p => p.id === product.id)
  )
  // 只取前6个
  return uniqueProducts.slice(0, 6)
})

// 轮播图数据
const banners = [
  {
    id: 1,
    title: '校园二手交易平台',
    subtitle: '让闲置物品找到新主人，让环保理念传递校园',
    bgColor: 'linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%)'
  },
  {
    id: 2,
    title: '新学期，新装备',
    subtitle: '学长学姐的优质闲置，助你开启新学期',
    bgColor: 'linear-gradient(135deg, rgba(238, 119, 128, 0.9) 0%, rgba(255, 193, 7, 0.9) 100%)'
  },
  {
    id: 3,
    title: '环保低碳，从二手开始',
    subtitle: '每一次二手交易，都是为地球减负',
    bgColor: 'linear-gradient(135deg, rgba(75, 192, 192, 0.9) 0%, rgba(54, 162, 235, 0.9) 100%)'
  }
]

// 加载数据
onMounted(async () => {
  try {
    // 加载商品分类
    await productStore.getCategories()
    
    // 加载热门商品
    await productStore.getHotProducts(4)
    
    // 加载推荐商品
    await productStore.getRecommendedProducts({ page: 1, pageSize: 4 })
    
    // 如果用户已登录，加载用户信息
    if (userStore.isLoggedIn) {
      await userStore.loadUserInfo()
      await userStore.loadFavorites()
    }
    
    // 启动轮播
    startBannerRotation()
  } catch (error) {
    console.error('首页数据加载失败', error)
  }
})

const goToProducts = () => {
  router.push('/products')
}

const searchProducts = () => {
  if (!searchKeyword.value.trim()) {
    ElMessage.warning('请输入搜索关键词')
    return
  }
  // 添加到搜索历史
  productStore.addSearchHistory(searchKeyword.value)
  router.push({ path: '/products', query: { keyword: searchKeyword.value } })
}

const goToCategory = (categoryId) => {
  router.push({ path: '/products', query: { categoryId } })
}

// 轮播图相关函数
let bannerTimer = null

const startBannerRotation = () => {
  bannerTimer = setInterval(() => {
    currentSlide.value = (currentSlide.value + 1) % banners.length
  }, 5000)
}

const stopBannerRotation = () => {
  if (bannerTimer) {
    clearInterval(bannerTimer)
    bannerTimer = null
  }
}

const goToSlide = (index) => {
  currentSlide.value = index
}

const nextSlide = () => {
  currentSlide.value = (currentSlide.value + 1) % banners.length
}

const prevSlide = () => {
  currentSlide.value = (currentSlide.value - 1 + banners.length) % banners.length
}

// 用户评价数据
const testimonials = [
  {
    id: 1,
    content: '这个平台太棒了！我轻松卖出了闲置的 textbooks，也买到了价格实惠的电子产品。',
    name: '张三',
    role: '大三学生',
    rating: 5
  },
  {
    id: 2,
    content: '服务很好，卖家很守时，商品质量也符合描述。校园二手交易就应该这样便捷！',
    name: '李四',
    role: '研究生',
    rating: 4
  },
  {
    id: 3,
    content: '作为新生，在这里买到了很多学长学姐的笔记和资料，非常实用！',
    name: '王五',
    role: '大一新生',
    rating: 5
  }
]

const goToGuide = () => {
  router.push('/help')
}

// 处理图片加载失败
const handleImageError = (event) => {
  event.target.src = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300"%3E%3Crect width="300" height="300" fill="%23f0f0f0"/%3E%3Ctext x="50%25" y="50%25" font-family="Arial" font-size="20" fill="%23999" text-anchor="middle" dominant-baseline="middle"%3E暂无图片%3C/text%3E%3C/svg%3E'
}

// 切换收藏状态
const toggleFavorite = async (product) => {
  // 检查是否登录
  if (!userStore.isLoggedIn) {
    ElMessage.warning('请先登录后收藏')
    router.push('/login')
    return
  }
  
  try {
    // 检查是否已收藏
    const isFavorite = userStore.favorites.some(fav => fav.productId === product.id)
    
    if (isFavorite) {
      // 取消收藏
      await userStore.removeFavorite(product.id)
      product.favorite = false
      ElMessage.info('已取消收藏')
    } else {
      // 添加收藏
      await userStore.addFavorite(product.id)
      product.favorite = true
      ElMessage.success('收藏成功')
    }
    
    // 重新加载收藏列表
    await userStore.loadFavorites()
  } catch (error) {
    ElMessage.error('操作失败，请重试')
    console.error('收藏操作失败', error)
  }
}
</script>

<style scoped>
.home-container {
  width: 100%;
}

.banner {
    height: 600px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    overflow: hidden;
    margin-bottom: 0;
  }
  
  .banner-slides {
    position: relative;
    width: 100%;
    height: 100%;
  }
  
  .banner-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
  }
  
  .banner-slide.active {
    opacity: 1;
  }
  
  .banner-indicators {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 2;
  }
  
  .indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
  }
  
  .indicator.active {
    width: 36px;
    border-radius: 6px;
    background: white;
  }
  
  .banner-control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    z-index: 2;
  }
  
  .banner-control:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
  }
  
  .banner-prev {
    left: 30px;
  }
  
  .banner-next {
    right: 30px;
  }

  .banner-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,%3Csvg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z" fill="%23ffffff" fill-opacity="0.1" fill-rule="evenodd"/%3E%3C/svg%3E');
    z-index: 0;
  }

  .banner-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    animation: fadeInUp 1s ease-out;
  }

  .banner-title {
    font-size: 56px;
    margin-bottom: 20px;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .banner-subtitle {
    font-size: 24px;
    margin-bottom: 30px;
    opacity: 0.95;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
  }

  .banner-button {
    background: white;
    color: #667eea;
    border: none;
    padding: 12px 32px;
    font-size: 18px;
    border-radius: 50px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
  }

  .banner-button:hover {
    background: #f8f9fa;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.3);
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

.search-section {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    gap: 0;
    position: relative;
    top: -40px;
    z-index: 20;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
  }

  .search-input {
    width: 600px;
    border-radius: 25px 0 0 25px;
    border-right: none;
    height: 60px;
    font-size: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  }

  .search-section .el-button {
    height: 60px;
    border-radius: 0 25px 25px 0;
    padding: 0 30px;
    font-size: 16px;
    background-color: #667eea;
    border-color: #667eea;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
  }

  .search-section .el-button:hover {
    background-color: #5a67d8;
    border-color: #5a67d8;
    transform: translateY(-2px);
  }

  .categories-section {
    padding: 60px 0;
    background-color: white;
    margin-bottom: 0;
    position: relative;
    z-index: 10;
  }

  .categories-section h2 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 32px;
    color: #333;
    position: relative;
  }

  .categories-section h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 15px auto 0;
    border-radius: 2px;
  }

  .category-list {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    max-width: 1000px;
    margin: 0 auto;
  }

  .category-item {
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 120px;
    padding: 20px;
    border-radius: 12px;
  }

  .category-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  }

  .category-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: bold;
    color: white;
    margin: 0 auto 15px;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
  }

  .category-item:hover .category-icon {
    transform: scale(1.1);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.3);
  }

  .category-item span {
    font-size: 18px;
    color: #333;
    font-weight: 500;
  }

.featured-products-section {
    padding: 80px 0;
    background-color: #f8f9fa;
    margin-bottom: 0;
  }

  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
  }

  .section-header h2 {
    font-size: 32px;
    color: #333;
    position: relative;
    padding-left: 20px;
  }

  .section-header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
  }

  .section-header .el-link {
    font-size: 16px;
    color: #667eea;
    transition: all 0.3s ease;
  }

  .section-header .el-link:hover {
    color: #5a67d8;
    transform: translateX(5px);
  }

  .product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
  }

  .product-card {
    background-color: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    border: none;
  }
  
  .card-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .card-hover:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.15);
  }

  .product-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.15);
  }

  .product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .product-card:hover::before {
    opacity: 1;
  }

  .product-discount {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff4d4f;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
  }

  .favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
  }

  .favorite-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
  }

  .favorite-btn.active {
    color: #fadb14;
    animation: bounce 0.3s ease;
  }

  @keyframes bounce {
    0%, 100% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.2);
    }
  }

  .product-image {
    width: 100%;
    height: 220px;
    overflow: hidden;
    position: relative;
  }

  .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    opacity: 1;
  }
  
  /* 骨架屏样式 */
  .loading-skeleton {
    background: #f0f0f0;
  }

  .product-card:hover .product-image img {
    transform: scale(1.05);
  }

  .product-info {
    padding: 20px;
  }

  .product-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
  }

  .product-price {
    font-size: 24px;
    font-weight: bold;
    color: #ff4d4f;
    margin-bottom: 12px;
    display: inline-block;
  }

  .product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #999;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
  }

  .advantages-section {
    padding: 80px 0;
    background-color: #ffffff;
    margin-bottom: 0;
  }

  .advantages-section h2 {
    text-align: center;
    margin-bottom: 60px;
    font-size: 32px;
    color: #333;
    position: relative;
  }

  .advantages-section h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 15px auto 0;
    border-radius: 2px;
  }

  .advantages-list {
    display: flex;
    justify-content: center;
    gap: 60px;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
  }

  .advantage-item {
    text-align: center;
    width: 220px;
    padding: 30px 20px;
    border-radius: 16px;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
  }

  .advantage-item:hover {
    transform: translateY(-10px);
    background-color: #ffffff;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  }

  .advantage-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 20px;
    color: white;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
  }

  .advantage-item h3 {
    margin-bottom: 15px;
    font-size: 20px;
    color: #333;
  }

  .advantage-item p {
    color: #666;
    font-size: 16px;
    line-height: 1.6;
  }

  /* 平台功能导航样式 */
  .features-nav-section {
    padding: 80px 0;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f0ff 100%);
    margin-bottom: 0;
  }

  .features-nav-section h2 {
    text-align: center;
    margin-bottom: 60px;
    font-size: 32px;
    color: #333;
    position: relative;
  }

  .features-nav-section h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 15px auto 0;
    border-radius: 2px;
  }

  .features-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
  }

  .feature-nav-card {
    background-color: white;
    border-radius: 16px;
    padding: 40px 25px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    border: none;
    position: relative;
    overflow: hidden;
  }

  .feature-nav-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }

  .feature-nav-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.2);
  }

  .feature-nav-icon {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 20px;
    transition: transform 0.3s ease;
  }

  .feature-nav-card:hover .feature-nav-icon {
    transform: scale(1.1);
  }

  .feature-nav-card h3 {
    font-size: 22px;
    margin-bottom: 15px;
    color: #333;
  }

  .feature-nav-card p {
    color: #666;
    font-size: 16px;
    line-height: 1.6;
  }

@media (max-width: 992px) {
  .banner {
    height: 500px;
  }
  
  .banner-title {
    font-size: 42px;
  }
  
  .banner-subtitle {
    font-size: 20px;
  }
}

@media (max-width: 768px) {
  .banner {
    height: 400px;
  }
  
  .banner-content h1 {
    font-size: 32px !important;
  }
  
  .banner-subtitle {
    font-size: 18px;
  }
  
  .search-input {
    width: 100%;
  }
  
  .category-list {
    gap: 20px;
  }
  
  .advantages-list {
    gap: 20px;
  }
  
  .banner-control {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .banner-prev {
    left: 15px;
  }
  
  .banner-next {
    right: 15px;
  }
  
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 576px) {
  .banner {
    height: 350px;
  }
  
  .banner-title {
    font-size: 28px;
  }
  
  .banner-subtitle {
    font-size: 16px;
    margin-bottom: 20px;
  }
  
  .banner-button {
    font-size: 16px;
    padding: 10px 24px;
  }
  
  .search-section {
    margin: 0 20px;
    margin-bottom: 30px;
    top: -30px;
  }
  
  .product-grid {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 0 20px;
  }
  
  .product-card {
    border-radius: 12px;
  }
  
  .product-info {
    padding: 15px;
  }
  
  .product-title {
    font-size: 16px;
  }
  
  .product-price {
    font-size: 20px;
  }
  
  .advantages-list {
    padding: 0 20px;
  }
  
  .advantage-item {
    width: 100%;
    max-width: 300px;
  }
  
  .features-nav-grid {
    padding: 0 20px;
  }
  
  .testimonials-carousel {
    padding: 0 20px;
  }
  
  .guide-steps {
    padding: 0 20px;
  }
}

/* 动画效果增强 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(50px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 骨架屏动画 */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
  .footer {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 80px 0 0;
    color: #ffffff;
  }

  .footer-content {
    display: flex;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    flex-wrap: wrap;
  }

  .footer-section {
    flex: 1;
    min-width: 250px;
    margin-right: 50px;
    margin-bottom: 50px;
  }

  .footer-section:last-child {
    margin-right: 0;
  }

  .footer-logo {
    font-size: 32px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 25px;
    text-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
    position: relative;
    display: inline-block;
  }

  .footer-logo::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
  }

  .footer-description {
    color: #adb5bd;
    margin-bottom: 30px;
    line-height: 1.8;
    font-size: 16px;
  }

  .footer-section h3 {
    font-size: 22px;
    margin-bottom: 25px;
    color: #ffffff;
    position: relative;
    display: inline-block;
  }

  .footer-section h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
  }

  .footer-links {
    list-style: none;
    padding: 0;
  }

  .footer-links li {
    margin-bottom: 15px;
    position: relative;
  }

  .footer-links a {
    color: #adb5bd;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-block;
    font-size: 16px;
  }

  .footer-links a:hover {
    color: #ffffff;
    transform: translateX(10px);
  }

  .footer-links a::before {
    content: '⟩';
    position: absolute;
    left: -20px;
    opacity: 0;
    transition: all 0.3s ease;
    color: #667eea;
  }

  .footer-links a:hover::before {
    opacity: 1;
    left: -15px;
  }

  .social-links {
    display: flex;
    gap: 20px;
    margin-top: 30px;
  }

  .social-link {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: all 0.3s ease;
    font-size: 20px;
    backdrop-filter: blur(10px);
  }

  .social-link:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
  }

  .footer-bottom {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 30px 0;
    text-align: center;
    color: #adb5bd;
    margin-top: 40px;
    backdrop-filter: blur(10px);
  }

  .footer-bottom p {
    margin: 0;
    font-size: 15px;
  }

  .footer-bottom a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s ease;
  }

  .footer-bottom a:hover {
    color: #ffffff;
    text-decoration: underline;
  }

/* 用户评价 */
  .testimonials-section {
    padding: 80px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
  }

  .testimonials-section h2 {
    font-size: 36px;
    margin-bottom: 60px;
    position: relative;
  }

  .testimonials-section h2::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    margin: 20px auto 0;
    border-radius: 2px;
  }

  .testimonials-carousel {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
  }

  .testimonial-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 16px;
    max-width: 350px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
  }

  .testimonial-item:hover {
    transform: translateY(-10px);
    background: rgba(255, 255, 255, 0.15);
  }

  .testimonial-text {
    font-size: 18px;
    line-height: 1.8;
    margin: 20px 0;
    font-style: italic;
  }

  .testimonial-author {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
  }

  .author-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
  }

  .author-title {
    font-size: 14px;
    opacity: 0.8;
  }

/* 使用指南 */
  .guide-section {
    padding: 80px 0;
    background-color: white;
  }

  .guide-steps {
    display: flex;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 30px;
  }

  .guide-step {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex: 1;
  }

  .step-number {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    flex-shrink: 0;
  }

  .step-content h3 {
    font-size: 20px;
    color: #333;
    margin-bottom: 10px;
  }

  .step-content p {
    font-size: 16px;
    color: #666;
    line-height: 1.5;
  }

  @media (max-width: 768px) {
    .guide-steps {
      flex-direction: column;
    }
  }
</style>